Skip to content

chore: add Python 3.11 support (requires-python >=3.11,<3.13) - #991

Merged
rchardx merged 1 commit into
mainfrom
fw/py311
Mar 6, 2026
Merged

rchardx merged 1 commit into
mainfrom
fw/py311

Conversation

@garrett4wade

@garrett4wade garrett4wade commented Mar 6, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Add Python 3.11 support by converting PEP 695 type parameter syntax (Python 3.12+) to the backward-compatible TypeVar/Generic pattern, and widening requires-python to >=3.11,<3.13. Docker image and CI workflows remain on Python 3.12 — no rebuild needed.

Reference implementation (code changes only): https://github.com/HwVanICI/AReaL/tree/downgrade-python-3.11

Related Issue

N/A

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring (no functional changes)
  • Performance improvement
  • Test coverage improvement

Changes

Python Source (PEP 695 → TypeVar/Generic)

  • areal/api/cli_args.py: def load_expr_config[ConfigT](...) → ConfigT = TypeVar("ConfigT") + regular function signature
  • areal/infra/async_task_runner.py: 4 classes (TimedResult[T], _TaskInput[T], _Task[T], AsyncTaskRunner[T]) → Generic[T] with T = TypeVar("T")
  • areal/infra/workflow_executor.py: BatchTaskDispatcher[TInput: WithTaskID, TResult] → Generic[TInput, TResult] with bound TypeVars
  • areal/models/mcore/common.py: def check_and_construct_configs[T: TransformerConfig](...) → T = TypeVar("T", bound=TransformerConfig)
  • areal/utils/functional/vocab_parallel.py: def _chunked_apply[T: (...)](...) → T = TypeVar("T", torch.Tensor, tuple[...])

Build & Configuration

  • pyproject.toml: requires-python widened to >=3.11,<3.13; added Python :: 3.11 classifier; ruff target-version → py311
  • uv.lock: Regenerated for dual Python 3.11 + 3.12 resolution (adds async-timeout for 3.11)

Unchanged

  • Dockerfile: Stays on Python 3.12 (no rebuild needed)
  • CI workflows: Stay on Python 3.12

Checklist

  • I have read the Contributing Guide
  • I have run formatting tools (pre-commit or manual)
  • I have run relevant unit tests and they pass
  • I have added tests for new functionality
  • I have updated documentation if needed
  • My branch is up to date with main
  • This PR introduces breaking changes (if yes, fill out details below)
  • If this PR changes documentation, I have built and previewed it locally with jb build docs
  • No critical issues raised by AI reviewers (/gemini review)

Breaking Change Details (if applicable):

N/A

Additional Context

  • All 5 modified Python files pass Python 3.11 AST parsing (verified with Python 3.11.14)
  • Zero PEP 695 syntax remaining (confirmed via AST-grep)
  • Ruff lint and format clean
  • Docker image and CI stay on Python 3.12, no rebuild required

@garrett4wade garrett4wade added the safe-to-test Ready to run unit-tests in a PR. label Mar 6, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request broadens the project's compatibility by downgrading the minimum required Python version from 3.12 to 3.11. This involved a comprehensive refactoring of modern Python 3.12 type parameter syntax to use the more widely supported TypeVar and Generic patterns. Additionally, all relevant build configurations, continuous integration/continuous deployment (CI/CD) workflows, and Docker environment setups were updated to ensure full functionality and consistency with Python 3.11.

Highlights

  • Python Version Downgrade: The project's required Python version has been downgraded from 3.12 to 3.11 to enhance compatibility.
  • Type Hinting Refactoring: PEP 695 type parameter syntax (Python 3.12+) has been converted to the backward-compatible TypeVar/Generic pattern for Python 3.11.
  • Build and CI/CD Configuration Updates: Project build configurations (pyproject.toml, uv.lock) and CI/CD workflows (.github/workflows/*.yml) have been updated to align with the new Python 3.11 requirement.
  • Dockerfile Adjustments: The Dockerfile was modified to use Python 3.11 for virtual environment creation and to correctly reference Python 3.11 site-packages paths.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .github/workflows/deploy-docs.yml
    • Changed the Python version from 3.12 to 3.11 in the documentation deployment workflow.
  • .github/workflows/install-test.yml
    • Updated the Python version from 3.12 to 3.11 in the test matrix and CUDA extras job.
  • Dockerfile
    • Updated the uv venv command to explicitly specify Python 3.11.
    • Modified site-packages paths for flash_attn_3 from python3.12 to python3.11.
  • areal/api/cli_args.py
    • Imported TypeVar from typing.
    • Defined ConfigT = TypeVar("ConfigT").
    • Converted the load_expr_config function's generic type parameter from PEP 695 syntax to use the defined ConfigT TypeVar.
  • areal/infra/async_task_runner.py
    • Imported Generic and TypeVar from typing.
    • Defined T = TypeVar("T").
    • Converted TimedResult, _TaskInput, _Task, and AsyncTaskRunner classes to use Generic[T] instead of PEP 695 syntax.
  • areal/infra/workflow_executor.py
    • Imported Generic and TypeVar from typing.
    • Defined TInput = TypeVar("TInput", bound=WithTaskID) and TResult = TypeVar("TResult").
    • Converted the BatchTaskDispatcher class to use Generic[TInput, TResult] instead of PEP 695 syntax.
  • areal/models/mcore/common.py
    • Imported TypeVar from typing.
    • Defined T = TypeVar("T", bound=TransformerConfig).
    • Converted the check_and_construct_configs function's generic type parameter from PEP 695 syntax to use the defined T TypeVar.
  • areal/utils/functional/vocab_parallel.py
    • Imported TypeVar from typing.
    • Defined T = TypeVar("T", torch.Tensor, tuple[torch.Tensor, torch.Tensor]).
    • Converted the _chunked_apply function's generic type parameter from PEP 695 syntax to use the defined T TypeVar.
  • pyproject.toml
    • Updated the requires-python field from >=3.12,<3.13 to >=3.11,<3.12.
    • Changed the Python classifier from 3.12 to 3.11.
    • Updated the ruff target-version from py312 to py311.
  • uv.lock
    • Regenerated to resolve dependencies for Python 3.11.
Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/deploy-docs.yml
    • .github/workflows/install-test.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly downgrades the Python requirement from 3.12 to 3.11. The changes to convert PEP 695 type parameter syntax to the backward-compatible TypeVar/Generic pattern are well-implemented across the Python source files. The updates to pyproject.toml and CI workflows are also consistent with the downgrade. However, I've found a critical issue in the Dockerfile related to a hardcoded dependency installation that will likely cause the build to fail.

Comment thread Dockerfile Outdated
@garrett4wade garrett4wade changed the title chore: downgrade Python requirement from 3.12 to 3.11 chore: add Python 3.11 support (requires-python >=3.11,<3.13) Mar 6, 2026
chore: add Python 3.11 support (requires-python >=3.11,<3.13)

Convert PEP 695 type parameter syntax (Python 3.12+) to TypeVar/Generic
(Python 3.11 compatible) across 5 source files. Widen requires-python to
>=3.11,<3.13 to support both Python 3.11 and 3.12. Docker image and CI
workflows remain on Python 3.12.

Key changes:
- Replace class[T]/def[T] PEP 695 syntax with TypeVar + Generic[T]
- pyproject.toml: requires-python >=3.11,<3.13, add 3.11 classifier
- ruff target-version py311 (lowest supported version)
- Regenerate uv.lock for dual 3.11+3.12 resolution
@garrett4wade garrett4wade added safe-to-test Ready to run unit-tests in a PR. and removed safe-to-test Ready to run unit-tests in a PR. labels Mar 6, 2026

@rchardx rchardx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rchardx
rchardx merged commit 550656f into main Mar 6, 2026
8 checks passed
@rchardx
rchardx deleted the fw/py311 branch March 6, 2026 12:13
dingzhiqiang pushed a commit that referenced this pull request Mar 16, 2026
Convert PEP 695 type parameter syntax (Python 3.12+) to TypeVar/Generic
(Python 3.11 compatible) across 5 source files. Widen requires-python to
>=3.11,<3.13 to support both Python 3.11 and 3.12. Docker image and CI
workflows remain on Python 3.12.

Key changes:
- Replace class[T]/def[T] PEP 695 syntax with TypeVar + Generic[T]
- pyproject.toml: requires-python >=3.11,<3.13, add 3.11 classifier
- ruff target-version py311 (lowest supported version)
- Regenerate uv.lock for dual 3.11+3.12 resolution
leandermaben pushed a commit to leandermaben/AReaL that referenced this pull request Mar 24, 2026
…project#991)

Convert PEP 695 type parameter syntax (Python 3.12+) to TypeVar/Generic
(Python 3.11 compatible) across 5 source files. Widen requires-python to
>=3.11,<3.13 to support both Python 3.11 and 3.12. Docker image and CI
workflows remain on Python 3.12.

Key changes:
- Replace class[T]/def[T] PEP 695 syntax with TypeVar + Generic[T]
- pyproject.toml: requires-python >=3.11,<3.13, add 3.11 classifier
- ruff target-version py311 (lowest supported version)
- Regenerate uv.lock for dual 3.11+3.12 resolution
SathyaGnanakumar pushed a commit to danielkiely/AReaL that referenced this pull request Apr 29, 2026
…project#991)

Convert PEP 695 type parameter syntax (Python 3.12+) to TypeVar/Generic
(Python 3.11 compatible) across 5 source files. Widen requires-python to
>=3.11,<3.13 to support both Python 3.11 and 3.12. Docker image and CI
workflows remain on Python 3.12.

Key changes:
- Replace class[T]/def[T] PEP 695 syntax with TypeVar + Generic[T]
- pyproject.toml: requires-python >=3.11,<3.13, add 3.11 classifier
- ruff target-version py311 (lowest supported version)
- Regenerate uv.lock for dual 3.11+3.12 resolution

This branch was previously deployed

1 inactive deployment
AReaL-unittests — 1a13cd57 Deployed Mar 6, 2026 by garrett4wade via Run AReaL tests #554
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe-to-test Ready to run unit-tests in a PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants